package cz.service;

import cz.dao.TokenRepositoty;
import cz.dto.AccessToken;
import cz.dto.token.Token;
import cz.util.wx.WeixinUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

/**
 * Created by 顾志杰 on 2018/6/11.
 */
@Component
@Service
public class timeService {
    @Autowired
    TokenRepositoty tokenRepositoty;
    //    每60分钟启动
    @Scheduled(cron = "0 0/60 * * * ?")
    public void timerToNow(){
        AccessToken token =  WeixinUtil.getAccessToken("wxb3618ab148a1747a","bf2f82246f9df8f0ada7d64e09e23b0c");
        Token token1 = new Token(token.getToken());
        try {
            tokenRepositoty.save(token1);
            System.out.println("成功");
        }catch (Exception e){
            System.out.println("失败");
        }

    }

}
